// Written by Dale J Williams.
// Licensed under MPL 1.1 unless otherwise specified. 
// http://www.mozilla.org/MPL/MPL-1.1.html

package engineDJW.map {
	
	import engineDJW.interfaces.IBounds;
	import flash.display.Sprite;
	import flash.geom.Rectangle;
	
	/**
	 * ...
	 * @author Dale J Williams
	 */
	public class MapPiece extends Sprite implements IBounds {
		
		protected var _width	:Number = 0;
		protected var _height	:Number = 0;
		
		protected var _hit		:Sprite;
		
		protected var _bounds	:Rectangle;
		
		public function MapPiece() { }
		
		public function withinBounds($x:Number, $y:Number):Boolean {
			return $x > _bounds.left && $x < _bounds.right && $y > _bounds.top && $y < _bounds.bottom;
		}
		
		public function get left():Number { return x }
		public function get top():Number { return y }
		public function get right():Number { return _width }
		public function get bottom():Number { return _height }
		
		override public function get width():Number { return _width; }
		
		override public function get height():Number { return _height; }
		
		public function get hit():Sprite { return _hit || this; }
		
		public function get bounds():Rectangle { return _bounds; }		
		public function set bounds(value:Rectangle):void {
			_bounds = value;
		}
		
	}

}